########### MANUSCRIPT: The Role of Education and Attitudes in Cooking Fuel Choice: Evidence from two states in India
########### JOURNAL: ENERGY FOR SUSTAINABLE DEVELOPMENT
########### AUTHORS: CARLOS F. GOULD/1 AND JOHANNES URPELAINEN/2
########### AFFILIATIONS: 1/COLUMBIA UNIVERSITY MAILMAN SCHOOL OF PUBLIC HEALTH AND 2/JOHNS HOPKINS SCHOOL OF ADVANCED INTERNATIONAL STUDIES
########### PURPOSE: THIS IS CODE #2 THAT MAKES DESCRIPTIVE TABLES


######################### MAIN TEXT TABLE -----------------------------


# TABLE 1 -------------------------------------------------------------
# Summary statistics of dependent, explanatory, and control variables


descriptives <- data.frame(matrix(NA, 27, 2))
rownames(descriptives) <- c("Households (N)", 
                            "Has LPG", 
                            "Fraction Rural", 
                            "Age Respondent", 
                            "Male Chief Wage Earner", 
                            "Relationship of Respondent to CWE:", "CWE herself", "Wife", "Daughter/DIL", "Other", 
                            "Education CWE:", "Illiterate / No Formal Schooling", "Primary School", "Middle / High School", "Greater than High School",
                            "Religion:", "Hindu", "Muslim",
                            "Head of Household Caste:", "General", "OBC","Scheduled Caste", "Scheduled Tribe", 
                            "Mean # Adults", "Mean # Children (< 18 yrs old)",
                            "Median Total Monthly Expenditure", "Median Monthly Fuel Expenditures")
colnames(descriptives) <- c("Kerala", "Rajasthan")

# Sample Size
descriptives[1,1] <- nrow(kerala)
descriptives[1,2] <- nrow(rajasthan)

# Has LPG
descriptives[2,1] <- mean(kerala$Owns_LPG==1)
descriptives[2,2] <- mean(rajasthan$Owns_LPG==1)

# Rural==1, Urban==2
descriptives[3,1] <- mean(kerala$q2==1)
descriptives[3,2] <- mean(rajasthan$q2==1)

# Age of respondent (female > 18 yrs)
descriptives[4,1] <- mean(kerala$q19_1)
descriptives[4,2] <- mean(rajasthan$q19_1)

# Gender Chief Wage Earner (Male=1; Female=2)
descriptives[5,1] <- mean(kerala$q7==1)
descriptives[5,2] <- mean(rajasthan$q7==1)

# Relationship of respondent to CWE
# 1=CWE, 2=wife, 3=daughter/DIL, 4=granddaughter, 5=mother, 6=sister/SIL, 7=other

descriptives[6,1] <- ""
descriptives[6,2] <- ""

descriptives[7,1] <- mean(kerala$q20==1)
descriptives[7,2] <- mean(rajasthan$q20==1)
descriptives[8,1] <- mean(kerala$q20==2)
descriptives[8,2] <- mean(rajasthan$q20==2)
descriptives[9,1] <- mean(kerala$q20==3)
descriptives[9,2] <- mean(rajasthan$q20==3)
descriptives[10,1] <- mean(kerala$q20==4) + mean(kerala$q20==5) + mean(kerala$q20==6) + mean(kerala$q20==7)
descriptives[10,2] <- mean(rajasthan$q20==4) + mean(rajasthan$q20==5) + mean(rajasthan$q20==6) + mean(rajasthan$q20==7)

# Education CWE
#1=illiterate, 2=literate (no formal schooling), 3=primary, 4=middle, 5=high school, 6=senior secondary, 7=diploma/certificate, 8=graduate, 9=post graduate
descriptives[11,1] <- ""
descriptives[11,2] <- ""

descriptives[12,1] <- mean(kerala$q22==1) + mean(kerala$q22==2)
descriptives[12,2] <- mean(rajasthan$q22==1) + mean(rajasthan$q22==2)
descriptives[13,1] <- mean(kerala$q22==3)
descriptives[13,2] <- mean(rajasthan$q22==3)
descriptives[14,1] <- mean(kerala$q22==4) + mean(kerala$q22==5)
descriptives[14,2] <- mean(rajasthan$q22==4) + mean(rajasthan$q22==5)
descriptives[15,1] <- mean(kerala$q22==6) + mean(kerala$q22==7) + mean(kerala$q22==8) + mean(kerala$q22==9)
descriptives[15,2] <- mean(rajasthan$q22==6) + mean(rajasthan$q22==7) + mean(rajasthan$q22==8) + mean(rajasthan$q22==9)

#religion
#1=hindu, 2=muslim, 3=christian, 4=sikh, 6=jain
descriptives[16,1] <- ""
descriptives[16,2] <- ""
descriptives[17,1] <- mean(kerala$q26==1)
descriptives[17,2] <- mean(rajasthan$q26==1)
descriptives[18,1] <- mean(kerala$q26==2)
descriptives[18,2] <- mean(rajasthan$q26==2)

#caste of head of household
#1=general, 2=obc, 3=scheduled caste, 4=scheduled tribe, 9=dk/cs
descriptives[19,1] <- ""
descriptives[19,2] <- ""
descriptives[20,1] <- mean(kerala$q27==1)
descriptives[20,2] <- mean(rajasthan$q27==1)
descriptives[21,1] <- mean(kerala$q27==2)
descriptives[21,2] <- mean(rajasthan$q27==2)
descriptives[22,1] <- mean(kerala$q27==3)
descriptives[22,2] <- mean(rajasthan$q27==3)
descriptives[23,1] <- mean(kerala$q27==4)
descriptives[23,2] <- mean(rajasthan$q27==4)

#total number of adults
descriptives[24,1] <- mean(kerala$NumberAdults)
descriptives[24,2] <- mean(rajasthan$NumberAdults)

#total number of children < 18
descriptives[25,1] <- mean(kerala$NumberChildrenUnder18)
descriptives[25,2] <- mean(rajasthan$NumberChildrenUnder18)

# Monthly expenditure
descriptives[26,1] <- median(kerala$totalexpenditure)
descriptives[26,2] <- median(rajasthan$totalexpenditure)

#Fuel expenditure
descriptives[27,1] <- median(kerala$q30a1_3)
descriptives[27,2] <- median(rajasthan$q30a1_3)


descriptives

# Save as .tex

# stargazer(descriptives, summary=FALSE, float=FALSE, digits = 2,
#           out = "~/Tables/Table1.tex")



##### SUPPORTING INFORMATION TABLES -------------------


# TABLE A1 -----------------------------------------------------------------
# Was made by hand in excel drawing on Census data sources 


# TABLE A2 -----------------------------------------------------------------
# Summary statistics of dependent, explanatory, and control varaibles by CWE education categories 


########## KERALA

descriptives_ed_4 <- data.frame(matrix(NA, 22, 4))
rownames(descriptives_ed_4) <- c("Households (N)", "Has LPG", "Fraction Rural", "Age Respondent", "Male Chief Wage Earner", 
                                 "Relationship of Respondent to CWE:", "CWE herself", "Wife", "Daughter/DIL", "Other", 
                                 "Religion:", "Hindu", "Muslim",
                                 "Head of Household Caste:", "General", "OBC","Scheduled Caste", "Scheduled Tribe", 
                                 "Mean # Adults", "Mean # Children (<18 yrs old)",
                                 "Median Total Monthly Expenditure", "Median Monthly Fuel Expenditures")

colnames(descriptives_ed_4) <- c("Illiterate / No Formal Schooling", "Primary School", "Middle / High School", "Greater than High School")

# N
descriptives_ed_4[1,1] <- nrow(kerala_education_CWE_illiteratenoformal)
descriptives_ed_4[1,2] <- nrow(kerala_education_CWE_primary)
descriptives_ed_4[1,3] <- nrow(kerala_education_CWE_middlehigh)
descriptives_ed_4[1,4] <- nrow(kerala_education_CWE_greaterhigh)

# Owns LPG
descriptives_ed_4[2,1] <- mean(kerala_education_CWE_illiteratenoformal$Owns_LPG)
descriptives_ed_4[2,2] <- mean(kerala_education_CWE_primary$Owns_LPG)
descriptives_ed_4[2,3] <- mean(kerala_education_CWE_middlehigh$Owns_LPG)
descriptives_ed_4[2,4] <- mean(kerala_education_CWE_greaterhigh$Owns_LPG)

# Rural==1, Urban==2
descriptives_ed_4[3,1] <- mean(kerala_education_CWE_illiteratenoformal$Rural==1)
descriptives_ed_4[3,2] <- mean(kerala_education_CWE_primary$Rural==1)
descriptives_ed_4[3,3] <- mean(kerala_education_CWE_middlehigh$Rural==1)
descriptives_ed_4[3,4] <- mean(kerala_education_CWE_greaterhigh$Rural==1)

# Age of respondent (female > 18 yrs)
descriptives_ed_4[4,1] <- mean(kerala_education_CWE_illiteratenoformal$AgeRespondent)
descriptives_ed_4[4,2] <- mean(kerala_education_CWE_primary$AgeRespondent)
descriptives_ed_4[4,3] <- mean(kerala_education_CWE_middlehigh$AgeRespondent)
descriptives_ed_4[4,4] <- mean(kerala_education_CWE_greaterhigh$AgeRespondent)

# Gender Chief Wage Earner (Male=1; Female=2)
descriptives_ed_4[5,1] <- mean(kerala_education_CWE_illiteratenoformal$q7==1)
descriptives_ed_4[5,2] <- mean(kerala_education_CWE_primary$q7==1)
descriptives_ed_4[5,3] <- mean(kerala_education_CWE_middlehigh$q7==1)
descriptives_ed_4[5,4] <- mean(kerala_education_CWE_greaterhigh$q7==1)

# Relationship of respondent to CWE
# 1=CWE, 2=wife, 3=daughter/DIL, 4=granddaughter, 5=mother, 6=sister/SIL, 7=other

descriptives_ed_4[6,1] <- ""
descriptives_ed_4[6,2] <- ""
descriptives_ed_4[6,3] <- ""
descriptives_ed_4[6,4] <- ""

descriptives_ed_4[7,1] <- mean(kerala_education_CWE_illiteratenoformal$q20==1)
descriptives_ed_4[7,2] <- mean(kerala_education_CWE_primary$q20==1)
descriptives_ed_4[7,3] <- mean(kerala_education_CWE_middlehigh$q20==1)
descriptives_ed_4[7,4] <- mean(kerala_education_CWE_greaterhigh$q20==1)

descriptives_ed_4[8,1] <- mean(kerala_education_CWE_illiteratenoformal$q20==2)
descriptives_ed_4[8,2] <- mean(kerala_education_CWE_primary$q20==2)
descriptives_ed_4[8,3] <- mean(kerala_education_CWE_middlehigh$q20==2)
descriptives_ed_4[8,4] <- mean(kerala_education_CWE_greaterhigh$q20==2)

descriptives_ed_4[9,1] <- mean(kerala_education_CWE_illiteratenoformal$q20==3)
descriptives_ed_4[9,2] <- mean(kerala_education_CWE_primary$q20==3)
descriptives_ed_4[9,3] <- mean(kerala_education_CWE_middlehigh$q20==3)
descriptives_ed_4[9,4] <- mean(kerala_education_CWE_greaterhigh$q20==3)

descriptives_ed_4[10,1] <- mean(kerala_education_CWE_illiteratenoformal$q20==4) + mean(kerala_education_CWE_illiteratenoformal$q20==5) + mean(kerala_education_CWE_illiteratenoformal$q20==6) + mean(kerala_education_CWE_illiteratenoformal$q20==7)
descriptives_ed_4[10,2] <- mean(kerala_education_CWE_primary$q20==4) + mean(kerala_education_CWE_primary$q20==5) + mean(kerala_education_CWE_primary$q20==6) + mean(kerala_education_CWE_primary$q20==7)
descriptives_ed_4[10,3] <- mean(kerala_education_CWE_middlehigh$q20==4) + mean(kerala_education_CWE_middlehigh$q20==5) + mean(kerala_education_CWE_middlehigh$q20==6) + mean(kerala_education_CWE_middlehigh$q20==7)
descriptives_ed_4[10,4] <- mean(kerala_education_CWE_greaterhigh$q20==4) + mean(kerala_education_CWE_greaterhigh$q20==5) + mean(kerala_education_CWE_greaterhigh$q20==6) + mean(kerala_education_CWE_greaterhigh$q20==7)

#religion
#1=hindu, 2=muslim, 3=christian, 4=sikh, 6=jain
descriptives_ed_4[11,1] <- ""
descriptives_ed_4[11,2] <- ""
descriptives_ed_4[11,3] <- ""
descriptives_ed_4[11,4] <- ""

descriptives_ed_4[12,1] <- mean(kerala_education_CWE_illiteratenoformal$Religion_Hindu==1)
descriptives_ed_4[12,2] <- mean(kerala_education_CWE_primary$Religion_Hindu==1)
descriptives_ed_4[12,3] <- mean(kerala_education_CWE_middlehigh$Religion_Hindu==1)
descriptives_ed_4[12,4] <- mean(kerala_education_CWE_greaterhigh$Religion_Hindu==1)

descriptives_ed_4[13,1] <- mean(kerala_education_CWE_illiteratenoformal$Religion_Muslim==1)
descriptives_ed_4[13,2] <- mean(kerala_education_CWE_primary$Religion_Muslim==1)
descriptives_ed_4[13,3] <- mean(kerala_education_CWE_middlehigh$Religion_Muslim==1)
descriptives_ed_4[13,4] <- mean(kerala_education_CWE_greaterhigh$Religion_Muslim==1)

#caste of head of household
#1=general, 2=obc, 3=scheduled caste, 4=scheduled tribe, 9=dk/cs
descriptives_ed_4[14,1] <- ""
descriptives_ed_4[14,2] <- ""
descriptives_ed_4[14,3] <- ""
descriptives_ed_4[14,4] <- ""

descriptives_ed_4[15,1] <- mean(kerala_education_CWE_illiteratenoformal$Caste_General==1)
descriptives_ed_4[15,2] <- mean(kerala_education_CWE_primary$Caste_General==1)
descriptives_ed_4[15,3] <- mean(kerala_education_CWE_middlehigh$Caste_General==1)
descriptives_ed_4[15,4] <- mean(kerala_education_CWE_greaterhigh$Caste_General==1)

descriptives_ed_4[16,1] <- mean(kerala_education_CWE_illiteratenoformal$Caste_OBC==1)
descriptives_ed_4[16,2] <- mean(kerala_education_CWE_primary$Caste_OBC==1)
descriptives_ed_4[16,3] <- mean(kerala_education_CWE_middlehigh$Caste_OBC==1)
descriptives_ed_4[16,4] <- mean(kerala_education_CWE_greaterhigh$Caste_OBC==1)

descriptives_ed_4[17,1] <- mean(kerala_education_CWE_illiteratenoformal$Caste_ScheduledCaste==1)
descriptives_ed_4[17,2] <- mean(kerala_education_CWE_primary$Caste_ScheduledCaste==1)
descriptives_ed_4[17,3] <- mean(kerala_education_CWE_middlehigh$Caste_ScheduledCaste==1)
descriptives_ed_4[17,4] <- mean(kerala_education_CWE_greaterhigh$Caste_ScheduledCaste==1)

descriptives_ed_4[18,1] <- mean(kerala_education_CWE_illiteratenoformal$Caste_ScheduledTribe==1)
descriptives_ed_4[18,2] <- mean(kerala_education_CWE_primary$Caste_ScheduledTribe==1)
descriptives_ed_4[18,3] <- mean(kerala_education_CWE_middlehigh$Caste_ScheduledTribe==1)
descriptives_ed_4[18,4] <- mean(kerala_education_CWE_greaterhigh$Caste_ScheduledTribe==1)

#Tabulations
#total number of adults
descriptives_ed_4[19,1] <- mean(kerala_education_CWE_illiteratenoformal$NumberAdults)
descriptives_ed_4[19,2] <- mean(kerala_education_CWE_primary$NumberAdults)
descriptives_ed_4[19,3] <- mean(kerala_education_CWE_middlehigh$NumberAdults)
descriptives_ed_4[19,4] <- mean(kerala_education_CWE_greaterhigh$NumberAdults)

#total number of children < 18
descriptives_ed_4[20,1] <- mean(kerala_education_CWE_illiteratenoformal$NumberChildrenUnder18)
descriptives_ed_4[20,2] <- mean(kerala_education_CWE_primary$NumberChildrenUnder18)
descriptives_ed_4[20,3] <- mean(kerala_education_CWE_middlehigh$NumberChildrenUnder18)
descriptives_ed_4[20,4] <- mean(kerala_education_CWE_greaterhigh$NumberChildrenUnder18)

# Monthly expenditure

descriptives_ed_4[21,1] <- median(kerala_education_CWE_illiteratenoformal$totalexpenditure, na.rm=F)
descriptives_ed_4[21,2] <- median(kerala_education_CWE_primary$totalexpenditure, na.rm=F)
descriptives_ed_4[21,3] <- median(kerala_education_CWE_middlehigh$totalexpenditure, na.rm=F)
descriptives_ed_4[21,4] <- median(kerala_education_CWE_greaterhigh$totalexpenditure, na.rm=F)

#Fuel expenditure
descriptives_ed_4[22,1] <- median(kerala_education_CWE_illiteratenoformal$q30a1_3)
descriptives_ed_4[22,2] <- median(kerala_education_CWE_primary$q30a1_3)
descriptives_ed_4[22,3] <- median(kerala_education_CWE_middlehigh$q30a1_3)
descriptives_ed_4[22,4] <- median(kerala_education_CWE_greaterhigh$q30a1_3)

######## RAJASTHAN

descriptives_r_ed_4 <- data.frame(matrix(NA, 22, 4))
rownames(descriptives_r_ed_4) <- c("Households (N)", "Has LPG", "Fraction Rural", "Age Respondent", "Male Chief Wage Earner", 
                                   "Relationship of Respondent to CWE:", "CWE herself", "Wife", "Daughter/DIL", "Other", 
                                   "Religion:", "Hindu", "Muslim",
                                   "Head of Household Caste:", "General", "OBC","Scheduled Caste", "Scheduled Tribe", 
                                   "Mean # Adults", "Mean # Children (<18 yrs old)",
                                   "Median Total Monthly Expenditure", "Median Monthly Fuel Expenditures")

colnames(descriptives_r_ed_4) <- c("Illiterate / No Formal Schooling", "Primary School", "Middle / High School", "Greater than High School")

# N
descriptives_r_ed_4[1,1] <- nrow(rajasthan_education_CWE_illiteratenoformal)
descriptives_r_ed_4[1,2] <- nrow(rajasthan_education_CWE_primary)
descriptives_r_ed_4[1,3] <- nrow(rajasthan_education_CWE_middlehigh)
descriptives_r_ed_4[1,4] <- nrow(rajasthan_education_CWE_greaterhigh)

# Owns LPG
descriptives_r_ed_4[2,1] <- mean(rajasthan_education_CWE_illiteratenoformal$Owns_LPG)
descriptives_r_ed_4[2,2] <- mean(rajasthan_education_CWE_primary$Owns_LPG)
descriptives_r_ed_4[2,3] <- mean(rajasthan_education_CWE_middlehigh$Owns_LPG)
descriptives_r_ed_4[2,4] <- mean(rajasthan_education_CWE_greaterhigh$Owns_LPG)

# Rural==1, Urban==2
descriptives_r_ed_4[3,1] <- mean(rajasthan_education_CWE_illiteratenoformal$Rural==1)
descriptives_r_ed_4[3,2] <- mean(rajasthan_education_CWE_primary$Rural==1)
descriptives_r_ed_4[3,3] <- mean(rajasthan_education_CWE_middlehigh$Rural==1)
descriptives_r_ed_4[3,4] <- mean(rajasthan_education_CWE_greaterhigh$Rural==1)

# Age of respondent (female > 18 yrs)
descriptives_r_ed_4[4,1] <- mean(rajasthan_education_CWE_illiteratenoformal$AgeRespondent)
descriptives_r_ed_4[4,2] <- mean(rajasthan_education_CWE_primary$AgeRespondent)
descriptives_r_ed_4[4,3] <- mean(rajasthan_education_CWE_middlehigh$AgeRespondent)
descriptives_r_ed_4[4,4] <- mean(rajasthan_education_CWE_greaterhigh$AgeRespondent)

# Gender Chief Wage Earner (Male=1; Female=2)
descriptives_r_ed_4[5,1] <- mean(rajasthan_education_CWE_illiteratenoformal$q7==1)
descriptives_r_ed_4[5,2] <- mean(rajasthan_education_CWE_primary$q7==1)
descriptives_r_ed_4[5,3] <- mean(rajasthan_education_CWE_middlehigh$q7==1)
descriptives_r_ed_4[5,4] <- mean(rajasthan_education_CWE_greaterhigh$q7==1)

# Relationship of respondent to CWE
# 1=CWE, 2=wife, 3=daughter/DIL, 4=granddaughter, 5=mother, 6=sister/SIL, 7=other

descriptives_r_ed_4[6,1] <- ""
descriptives_r_ed_4[6,2] <- ""
descriptives_r_ed_4[6,3] <- ""
descriptives_r_ed_4[6,4] <- ""

descriptives_r_ed_4[7,1] <- mean(rajasthan_education_CWE_illiteratenoformal$q20==1)
descriptives_r_ed_4[7,2] <- mean(rajasthan_education_CWE_primary$q20==1)
descriptives_r_ed_4[7,3] <- mean(rajasthan_education_CWE_middlehigh$q20==1)
descriptives_r_ed_4[7,4] <- mean(rajasthan_education_CWE_greaterhigh$q20==1)

descriptives_r_ed_4[8,1] <- mean(rajasthan_education_CWE_illiteratenoformal$q20==2)
descriptives_r_ed_4[8,2] <- mean(rajasthan_education_CWE_primary$q20==2)
descriptives_r_ed_4[8,3] <- mean(rajasthan_education_CWE_middlehigh$q20==2)
descriptives_r_ed_4[8,4] <- mean(rajasthan_education_CWE_greaterhigh$q20==2)

descriptives_r_ed_4[9,1] <- mean(rajasthan_education_CWE_illiteratenoformal$q20==3)
descriptives_r_ed_4[9,2] <- mean(rajasthan_education_CWE_primary$q20==3)
descriptives_r_ed_4[9,3] <- mean(rajasthan_education_CWE_middlehigh$q20==3)
descriptives_r_ed_4[9,4] <- mean(rajasthan_education_CWE_greaterhigh$q20==3)

descriptives_r_ed_4[10,1] <- mean(rajasthan_education_CWE_illiteratenoformal$q20==4) + mean(rajasthan_education_CWE_illiteratenoformal$q20==5) + mean(rajasthan_education_CWE_illiteratenoformal$q20==6) + mean(rajasthan_education_CWE_illiteratenoformal$q20==7)
descriptives_r_ed_4[10,2] <- mean(rajasthan_education_CWE_primary$q20==4) + mean(rajasthan_education_CWE_primary$q20==5) + mean(rajasthan_education_CWE_primary$q20==6) + mean(rajasthan_education_CWE_primary$q20==7)
descriptives_r_ed_4[10,3] <- mean(rajasthan_education_CWE_middlehigh$q20==4) + mean(rajasthan_education_CWE_middlehigh$q20==5) + mean(rajasthan_education_CWE_middlehigh$q20==6) + mean(rajasthan_education_CWE_middlehigh$q20==7)
descriptives_r_ed_4[10,4] <- mean(rajasthan_education_CWE_greaterhigh$q20==4) + mean(rajasthan_education_CWE_greaterhigh$q20==5) + mean(rajasthan_education_CWE_greaterhigh$q20==6) + mean(rajasthan_education_CWE_greaterhigh$q20==7)

#religion
#1=hindu, 2=muslim, 3=christian, 4=sikh, 6=jain
descriptives_r_ed_4[11,1] <- ""
descriptives_r_ed_4[11,2] <- ""
descriptives_r_ed_4[11,3] <- ""
descriptives_r_ed_4[11,4] <- ""

descriptives_r_ed_4[12,1] <- mean(rajasthan_education_CWE_illiteratenoformal$Religion_Hindu==1)
descriptives_r_ed_4[12,2] <- mean(rajasthan_education_CWE_primary$Religion_Hindu==1)
descriptives_r_ed_4[12,3] <- mean(rajasthan_education_CWE_middlehigh$Religion_Hindu==1)
descriptives_r_ed_4[12,4] <- mean(rajasthan_education_CWE_greaterhigh$Religion_Hindu==1)

descriptives_r_ed_4[13,1] <- mean(rajasthan_education_CWE_illiteratenoformal$Religion_Muslim==1)
descriptives_r_ed_4[13,2] <- mean(rajasthan_education_CWE_primary$Religion_Muslim==1)
descriptives_r_ed_4[13,3] <- mean(rajasthan_education_CWE_middlehigh$Religion_Muslim==1)
descriptives_r_ed_4[13,4] <- mean(rajasthan_education_CWE_greaterhigh$Religion_Muslim==1)

#caste of head of household
#1=general, 2=obc, 3=scheduled caste, 4=scheduled tribe, 9=dk/cs
descriptives_r_ed_4[14,1] <- ""
descriptives_r_ed_4[14,2] <- ""
descriptives_r_ed_4[14,3] <- ""
descriptives_r_ed_4[14,4] <- ""

descriptives_r_ed_4[15,1] <- mean(rajasthan_education_CWE_illiteratenoformal$Caste_General==1)
descriptives_r_ed_4[15,2] <- mean(rajasthan_education_CWE_primary$Caste_General==1)
descriptives_r_ed_4[15,3] <- mean(rajasthan_education_CWE_middlehigh$Caste_General==1)
descriptives_r_ed_4[15,4] <- mean(rajasthan_education_CWE_greaterhigh$Caste_General==1)

descriptives_r_ed_4[16,1] <- mean(rajasthan_education_CWE_illiteratenoformal$Caste_OBC==1)
descriptives_r_ed_4[16,2] <- mean(rajasthan_education_CWE_primary$Caste_OBC==1)
descriptives_r_ed_4[16,3] <- mean(rajasthan_education_CWE_middlehigh$Caste_OBC==1)
descriptives_r_ed_4[16,4] <- mean(rajasthan_education_CWE_greaterhigh$Caste_OBC==1)

descriptives_r_ed_4[17,1] <- mean(rajasthan_education_CWE_illiteratenoformal$Caste_ScheduledCaste==1)
descriptives_r_ed_4[17,2] <- mean(rajasthan_education_CWE_primary$Caste_ScheduledCaste==1)
descriptives_r_ed_4[17,3] <- mean(rajasthan_education_CWE_middlehigh$Caste_ScheduledCaste==1)
descriptives_r_ed_4[17,4] <- mean(rajasthan_education_CWE_greaterhigh$Caste_ScheduledCaste==1)

descriptives_r_ed_4[18,1] <- mean(rajasthan_education_CWE_illiteratenoformal$Caste_ScheduledTribe==1)
descriptives_r_ed_4[18,2] <- mean(rajasthan_education_CWE_primary$Caste_ScheduledTribe==1)
descriptives_r_ed_4[18,3] <- mean(rajasthan_education_CWE_middlehigh$Caste_ScheduledTribe==1)
descriptives_r_ed_4[18,4] <- mean(rajasthan_education_CWE_greaterhigh$Caste_ScheduledTribe==1)

#Tabulations
#total number of adults
descriptives_r_ed_4[19,1] <- mean(rajasthan_education_CWE_illiteratenoformal$NumberAdults)
descriptives_r_ed_4[19,2] <- mean(rajasthan_education_CWE_primary$NumberAdults)
descriptives_r_ed_4[19,3] <- mean(rajasthan_education_CWE_middlehigh$NumberAdults)
descriptives_r_ed_4[19,4] <- mean(rajasthan_education_CWE_greaterhigh$NumberAdults)

#total number of children < 18
descriptives_r_ed_4[20,1] <- mean(rajasthan_education_CWE_illiteratenoformal$NumberChildrenUnder18)
descriptives_r_ed_4[20,2] <- mean(rajasthan_education_CWE_primary$NumberChildrenUnder18)
descriptives_r_ed_4[20,3] <- mean(rajasthan_education_CWE_middlehigh$NumberChildrenUnder18)
descriptives_r_ed_4[20,4] <- mean(rajasthan_education_CWE_greaterhigh$NumberChildrenUnder18)

# Monthly expenditure

descriptives_r_ed_4[21,1] <- median(rajasthan_education_CWE_illiteratenoformal$totalexpenditure, na.rm=F)
descriptives_r_ed_4[21,2] <- median(rajasthan_education_CWE_primary$totalexpenditure, na.rm=F)
descriptives_r_ed_4[21,3] <- median(rajasthan_education_CWE_middlehigh$totalexpenditure, na.rm=F)
descriptives_r_ed_4[21,4] <- median(rajasthan_education_CWE_greaterhigh$totalexpenditure, na.rm=F)

#Fuel expenditure
descriptives_r_ed_4[22,1] <- median(rajasthan_education_CWE_illiteratenoformal$q30a1_3)
descriptives_r_ed_4[22,2] <- median(rajasthan_education_CWE_primary$q30a1_3)
descriptives_r_ed_4[22,3] <- median(rajasthan_education_CWE_middlehigh$q30a1_3)
descriptives_r_ed_4[22,4] <- median(rajasthan_education_CWE_greaterhigh$q30a1_3)

descriptives_joined <- descriptives_ed_4 %>%
  bind_cols(descriptives_r_ed_4)

rownames(descriptives_joined) <- c("Households (N)", "Has LPG", "Fraction Rural", "Age Respondent", "Male Chief Wage Earner", 
                                   "Relationship of Respondent to CWE:", "CWE herself", "Wife", "Daughter/DIL", "Other", 
                                   "Religion:", "Hindu", "Muslim",
                                   "Head of Household Caste:", "General", "OBC","Scheduled Caste", "Scheduled Tribe", 
                                   "Mean # Adults", "Mean # Children (<18 yrs old)",
                                   "Median Total Monthly Expenditure", "Median Monthly Fuel Expenditures")

descriptives_joined


# save as .tex, required some small formatting in Latex

# stargazer(descriptives_joined, summary=FALSE, float=FALSE, digits = 2,
#           out = "/Users/carlosgould/Dropbox/Kerala Rajasthan/Manuscript/Tables/November/descriptives_ed_joined.tex")


# TABLE A3 -------------------------------------------------------------
# Distribution of the percent of households in each CWE education level and highest
# female education level attained pair in Kerala households.


cwe_k_fem_ed_table <- table(kerala$Education_4_CWE, kerala$Education_female_4_category_new)
colnames(cwe_k_fem_ed_table) <- c("Illiterate / No Formal Schooling", "Primary School", "Middle / High School", "Greater than High School")
rownames(cwe_k_fem_ed_table) <- c("Illiterate / No Formal Schooling", "Primary School", "Middle / High School", "Greater than High School")

cwe_k_fem_ed_table1 <- round((as.data.frame.matrix(cwe_k_fem_ed_table / (3929-164)) * 100), digits = 2)

cwe_k_fem_ed_table1

# stargazer(cwe_fem_ed_table1, summary=FALSE, float=FALSE, digits = 2, 
#           out = "~/Tables/supp_k_cwe_fem_ed_table.tex")



# TABLE A4 -------------------------------------------------------------
# Distribution of the percent of households in each CWE education level and highest
# female spouse education level attained pair in Rajasthan households.

cwe_r_fem_ed_table <- table(rajasthan$Education_4_CWE, rajasthan$Education_4_FemaleSpouse)
colnames(cwe_r_fem_ed_table) <- c("Illiterate / No Formal Schooling", "Primary School", "Middle / High School", "Greater than High School")
rownames(cwe_r_fem_ed_table) <- c("Illiterate / No Formal Schooling", "Primary School", "Middle / High School", "Greater than High School")

cwe_r_fem_ed_table1 <- round((as.data.frame.matrix(cwe_r_fem_ed_table / (6077-185)) * 100),digits=2)

cwe_r_fem_ed_table1

# stargazer(cwe_r_fem_ed_table1, summary=FALSE, float=FALSE, digits = 2, 
#           out = "~/Tables/supp_r_cwe_fem_ed_table.tex")



# Table A5: -------------------------------------------------------------
# Summary statistics of dependent, explanatory, and control variables, by categories of the
# highest education level achieved by a female in Kerala households.



descriptives_fem_ed_4 <- data.frame(matrix(NA, 22, 4))
rownames(descriptives_fem_ed_4) <- c("Households (N)", "Has LPG", "Fraction Rural", "Age Respondent", "Male Chief Wage Earner", 
                                     "Relationship of Respondent to CWE:", "CWE herself", "Wife", "Daughter/DIL", "Other", 
                                     "Religion:", "Hindu", "Muslim",
                                     "Head of Household Caste:", "General", "OBC","Scheduled Caste", "Scheduled Tribe", 
                                     "Mean # Adults", "Mean # Children (<18 yrs old)",
                                     "Median Total Monthly Expenditure", "Median Monthly Fuel Expenditures")

colnames(descriptives_fem_ed_4) <- c("Illiterate / No Formal Schooling", "Primary School", "Middle / High School", "Greater than High School")

# N
descriptives_fem_ed_4[1,1] <- nrow(kerala_education_female_illiteratenoformal)
descriptives_fem_ed_4[1,2] <- nrow(kerala_education_female_primary)
descriptives_fem_ed_4[1,3] <- nrow(kerala_education_female_middlehigh)
descriptives_fem_ed_4[1,4] <- nrow(kerala_education_female_greaterhigh)

# Owns LPG
descriptives_fem_ed_4[2,1] <- round(mean(kerala_education_female_illiteratenoformal$Owns_LPG),2)
descriptives_fem_ed_4[2,2] <- round(mean(kerala_education_female_primary$Owns_LPG), 2)
descriptives_fem_ed_4[2,3] <- round(mean(kerala_education_female_middlehigh$Owns_LPG), 2)
descriptives_fem_ed_4[2,4] <- round(mean(kerala_education_female_greaterhigh$Owns_LPG), 2)

# Rural==1, Urban==2
descriptives_fem_ed_4[3,1] <- round(mean(kerala_education_female_illiteratenoformal$Rural==1), 2)
descriptives_fem_ed_4[3,2] <- round(mean(kerala_education_female_primary$Rural==1), 2)
descriptives_fem_ed_4[3,3] <- round(mean(kerala_education_female_middlehigh$Rural==1), 2)
descriptives_fem_ed_4[3,4] <- round(mean(kerala_education_female_greaterhigh$Rural==1), 2)

# Age of respondent (female > 18 yrs)
descriptives_fem_ed_4[4,1] <- round(mean(kerala_education_female_illiteratenoformal$AgeRespondent), 2)
descriptives_fem_ed_4[4,2] <- round(mean(kerala_education_female_primary$AgeRespondent), 2)
descriptives_fem_ed_4[4,3] <- round(mean(kerala_education_female_middlehigh$AgeRespondent), 2)
descriptives_fem_ed_4[4,4] <- round(mean(kerala_education_female_greaterhigh$AgeRespondent), 2)

# Gender Chief Wage Earner (Male=1; Female=2)
descriptives_fem_ed_4[5,1] <- round(mean(kerala_education_female_illiteratenoformal$q7==1), 2)
descriptives_fem_ed_4[5,2] <- round(mean(kerala_education_female_primary$q7==1), 2)
descriptives_fem_ed_4[5,3] <- round(mean(kerala_education_female_middlehigh$q7==1), 2)
descriptives_fem_ed_4[5,4] <- round(mean(kerala_education_female_greaterhigh$q7==1), 2)

# Relationship of respondent to CWE
# 1=CWE, 2=wife, 3=daughter/DIL, 4=granddaughter, 5=mother, 6=sister/SIL, 7=other

descriptives_fem_ed_4[6,1] <- ""
descriptives_fem_ed_4[6,2] <- ""
descriptives_fem_ed_4[6,3] <- ""
descriptives_fem_ed_4[6,4] <- ""

descriptives_fem_ed_4[7,1] <- round(mean(kerala_education_female_illiteratenoformal$q20==1), 2)
descriptives_fem_ed_4[7,2] <- round(mean(kerala_education_female_primary$q20==1), 2)
descriptives_fem_ed_4[7,3] <- round(mean(kerala_education_female_middlehigh$q20==1), 2)
descriptives_fem_ed_4[7,4] <- round(mean(kerala_education_female_greaterhigh$q20==1), 2)

descriptives_fem_ed_4[8,1] <- round(mean(kerala_education_female_illiteratenoformal$q20==2), 2)
descriptives_fem_ed_4[8,2] <- round(mean(kerala_education_female_primary$q20==2), 2)
descriptives_fem_ed_4[8,3] <- round(mean(kerala_education_female_middlehigh$q20==2), 2)
descriptives_fem_ed_4[8,4] <- round(mean(kerala_education_female_greaterhigh$q20==2), 2)

descriptives_fem_ed_4[9,1] <- round(mean(kerala_education_female_illiteratenoformal$q20==3), 2)
descriptives_fem_ed_4[9,2] <- round(mean(kerala_education_female_primary$q20==3), 2)
descriptives_fem_ed_4[9,3] <- round(mean(kerala_education_female_middlehigh$q20==3), 2)
descriptives_fem_ed_4[9,4] <- round(mean(kerala_education_female_greaterhigh$q20==3), 2)

descriptives_fem_ed_4[10,1] <- round(mean(kerala_education_female_illiteratenoformal$q20==4) + mean(kerala_education_female_illiteratenoformal$q20==5) + mean(kerala_education_female_illiteratenoformal$q20==6) + mean(kerala_education_female_illiteratenoformal$q20==7), 2)
descriptives_fem_ed_4[10,2] <- round(mean(kerala_education_female_primary$q20==4) + mean(kerala_education_female_primary$q20==5) + mean(kerala_education_female_primary$q20==6) + mean(kerala_education_female_primary$q20==7), 2)
descriptives_fem_ed_4[10,3] <- round(mean(kerala_education_female_middlehigh$q20==4) + mean(kerala_education_female_middlehigh$q20==5) + mean(kerala_education_female_middlehigh$q20==6) + mean(kerala_education_female_middlehigh$q20==7), 2)
descriptives_fem_ed_4[10,4] <- round(mean(kerala_education_female_greaterhigh$q20==4) + mean(kerala_education_female_greaterhigh$q20==5) + mean(kerala_education_female_greaterhigh$q20==6) + mean(kerala_education_female_greaterhigh$q20==7), 2)

#religion
#1=hindu, 2=muslim, 3=christian, 4=sikh, 6=jain
descriptives_fem_ed_4[11,1] <- ""
descriptives_fem_ed_4[11,2] <- ""
descriptives_fem_ed_4[11,3] <- ""
descriptives_fem_ed_4[11,4] <- ""

descriptives_fem_ed_4[12,1] <- round(mean(kerala_education_female_illiteratenoformal$Religion_Hindu==1), 2)
descriptives_fem_ed_4[12,2] <- round(mean(kerala_education_female_primary$Religion_Hindu==1), 2)
descriptives_fem_ed_4[12,3] <- round(mean(kerala_education_female_middlehigh$Religion_Hindu==1), 2)
descriptives_fem_ed_4[12,4] <- round(mean(kerala_education_female_greaterhigh$Religion_Hindu==1), 2)

descriptives_fem_ed_4[13,1] <- round(mean(kerala_education_female_illiteratenoformal$Religion_Muslim==1), 2)
descriptives_fem_ed_4[13,2] <- round(mean(kerala_education_female_primary$Religion_Muslim==1), 2)
descriptives_fem_ed_4[13,3] <- round(mean(kerala_education_female_middlehigh$Religion_Muslim==1), 2)
descriptives_fem_ed_4[13,4] <- round(mean(kerala_education_female_greaterhigh$Religion_Muslim==1), 2)

#caste of head of household
#1=general, 2=obc, 3=scheduled caste, 4=scheduled tribe, 9=dk/cs
descriptives_fem_ed_4[14,1] <- ""
descriptives_fem_ed_4[14,2] <- ""
descriptives_fem_ed_4[14,3] <- ""
descriptives_fem_ed_4[14,4] <- ""

descriptives_fem_ed_4[15,1] <- round(mean(kerala_education_female_illiteratenoformal$Caste_General==1), 2)
descriptives_fem_ed_4[15,2] <- round(mean(kerala_education_female_primary$Caste_General==1), 2)
descriptives_fem_ed_4[15,3] <- round(mean(kerala_education_female_middlehigh$Caste_General==1), 2)
descriptives_fem_ed_4[15,4] <- round(mean(kerala_education_female_greaterhigh$Caste_General==1), 2)

descriptives_fem_ed_4[16,1] <- round(mean(kerala_education_female_illiteratenoformal$Caste_OBC==1), 2)
descriptives_fem_ed_4[16,2] <- round(mean(kerala_education_female_primary$Caste_OBC==1), 2)
descriptives_fem_ed_4[16,3] <- round(mean(kerala_education_female_middlehigh$Caste_OBC==1), 2)
descriptives_fem_ed_4[16,4] <- round(mean(kerala_education_female_greaterhigh$Caste_OBC==1), 2)

descriptives_fem_ed_4[17,1] <- round(mean(kerala_education_female_illiteratenoformal$Caste_ScheduledCaste==1), 2)
descriptives_fem_ed_4[17,2] <- round(mean(kerala_education_female_primary$Caste_ScheduledCaste==1), 2)
descriptives_fem_ed_4[17,3] <- round(mean(kerala_education_female_middlehigh$Caste_ScheduledCaste==1), 2)
descriptives_fem_ed_4[17,4] <- round(mean(kerala_education_female_greaterhigh$Caste_ScheduledCaste==1), 2)

descriptives_fem_ed_4[18,1] <- round(mean(kerala_education_female_illiteratenoformal$Caste_ScheduledTribe==1), 2)
descriptives_fem_ed_4[18,2] <- round(mean(kerala_education_female_primary$Caste_ScheduledTribe==1), 2)
descriptives_fem_ed_4[18,3] <- round(mean(kerala_education_female_middlehigh$Caste_ScheduledTribe==1), 2)
descriptives_fem_ed_4[18,4] <- round(mean(kerala_education_female_greaterhigh$Caste_ScheduledTribe==1), 2)

#Tabulations
#total number of adults
descriptives_fem_ed_4[19,1] <- round(mean(kerala_education_female_illiteratenoformal$NumberAdults), 2)
descriptives_fem_ed_4[19,2] <- round(mean(kerala_education_female_primary$NumberAdults), 2)
descriptives_fem_ed_4[19,3] <- round(mean(kerala_education_female_middlehigh$NumberAdults), 2)
descriptives_fem_ed_4[19,4] <- round(mean(kerala_education_female_greaterhigh$NumberAdults), 2)

#total number of children < 18
descriptives_fem_ed_4[20,1] <- round(mean(kerala_education_female_illiteratenoformal$NumberChildrenUnder18), 2)
descriptives_fem_ed_4[20,2] <- round(mean(kerala_education_female_primary$NumberChildrenUnder18), 2)
descriptives_fem_ed_4[20,3] <- round(mean(kerala_education_female_middlehigh$NumberChildrenUnder18), 2)
descriptives_fem_ed_4[20,4] <- round(mean(kerala_education_female_greaterhigh$NumberChildrenUnder18), 2)

# Monthly expenditure

descriptives_fem_ed_4[21,1] <- round(median(kerala_education_female_illiteratenoformal$totalexpenditure, na.rm=F), 2)
descriptives_fem_ed_4[21,2] <- round(median(kerala_education_female_primary$totalexpenditure, na.rm=F), 2)
descriptives_fem_ed_4[21,3] <- round(median(kerala_education_female_middlehigh$totalexpenditure, na.rm=F), 2)
descriptives_fem_ed_4[21,4] <- round(median(kerala_education_female_greaterhigh$totalexpenditure, na.rm=F), 2)

#Fuel expenditure
descriptives_fem_ed_4[22,1] <- median(kerala_education_female_illiteratenoformal$q30a1_3)
descriptives_fem_ed_4[22,2] <- median(kerala_education_female_primary$q30a1_3)
descriptives_fem_ed_4[22,3] <- median(kerala_education_female_middlehigh$q30a1_3)
descriptives_fem_ed_4[22,4] <- median(kerala_education_female_greaterhigh$q30a1_3)

descriptives_fem_ed_4

# stargazer(descriptives_fem_ed_4, summary=FALSE, float=FALSE, digits = 2, 
#           out = "~/Tables/ker_fem_ed4_sumstats.tex")



# Table A6: -------------------------------------------------------------
# Summary statistics of dependent, explanatory, and control variables, by categories of
# the highest education level achieved by the CWE's female spouse in Rajasthan households.



descriptives_r_f_ed_4 <- data.frame(matrix(NA, 22, 4))
rownames(descriptives_r_f_ed_4) <- c("Households (N)", "Has LPG", "Fraction Rural", "Age Respondent", "Male Chief Wage Earner", 
                                     "Relationship of Respondent to CWE:", "CWE herself", "Wife", "Daughter/DIL", "Other", 
                                     "Religion:", "Hindu", "Muslim",
                                     "Head of Household Caste:", "General", "OBC","Scheduled Caste", "Scheduled Tribe", 
                                     "Mean # Adults", "Mean # Children (<18 yrs old)",
                                     "Median Total Monthly Expenditure", "Median Monthly Fuel Expenditures")

colnames(descriptives_r_f_ed_4) <- c("Illiterate / No Formal Schooling", "Primary School", "Middle / High School", "Greater than High School")

# N
descriptives_r_f_ed_4[1,1] <- nrow(rajasthan_education_female_illiteratenoformal)
descriptives_r_f_ed_4[1,2] <- nrow(rajasthan_education_female_primary)
descriptives_r_f_ed_4[1,3] <- nrow(rajasthan_education_female_middlehigh)
descriptives_r_f_ed_4[1,4] <- nrow(rajasthan_education_female_greaterhigh)

# Owns LPG
descriptives_r_f_ed_4[2,1] <- mean(rajasthan_education_female_illiteratenoformal$Owns_LPG)
descriptives_r_f_ed_4[2,2] <- mean(rajasthan_education_female_primary$Owns_LPG)
descriptives_r_f_ed_4[2,3] <- mean(rajasthan_education_female_middlehigh$Owns_LPG)
descriptives_r_f_ed_4[2,4] <- mean(rajasthan_education_female_greaterhigh$Owns_LPG)

# Rural==1, Urban==2
descriptives_r_f_ed_4[3,1] <- mean(rajasthan_education_female_illiteratenoformal$Rural==1)
descriptives_r_f_ed_4[3,2] <- mean(rajasthan_education_female_primary$Rural==1)
descriptives_r_f_ed_4[3,3] <- mean(rajasthan_education_female_middlehigh$Rural==1)
descriptives_r_f_ed_4[3,4] <- mean(rajasthan_education_female_greaterhigh$Rural==1)

# Age of respondent (female > 18 yrs)
descriptives_r_f_ed_4[4,1] <- mean(rajasthan_education_female_illiteratenoformal$AgeRespondent)
descriptives_r_f_ed_4[4,2] <- mean(rajasthan_education_female_primary$AgeRespondent)
descriptives_r_f_ed_4[4,3] <- mean(rajasthan_education_female_middlehigh$AgeRespondent)
descriptives_r_f_ed_4[4,4] <- mean(rajasthan_education_female_greaterhigh$AgeRespondent)

# Gender Chief Wage Earner (Male=1; Female=2)
descriptives_r_f_ed_4[5,1] <- mean(rajasthan_education_female_illiteratenoformal$q7==1)
descriptives_r_f_ed_4[5,2] <- mean(rajasthan_education_female_primary$q7==1)
descriptives_r_f_ed_4[5,3] <- mean(rajasthan_education_female_middlehigh$q7==1)
descriptives_r_f_ed_4[5,4] <- mean(rajasthan_education_female_greaterhigh$q7==1)

# Relationship of respondent to CWE
# 1=CWE, 2=wife, 3=daughter/DIL, 4=granddaughter, 5=mother, 6=sister/SIL, 7=other

descriptives_r_f_ed_4[6,1] <- ""
descriptives_r_f_ed_4[6,2] <- ""
descriptives_r_f_ed_4[6,3] <- ""
descriptives_r_f_ed_4[6,4] <- ""

descriptives_r_f_ed_4[7,1] <- mean(rajasthan_education_female_illiteratenoformal$q20==1)
descriptives_r_f_ed_4[7,2] <- mean(rajasthan_education_female_primary$q20==1)
descriptives_r_f_ed_4[7,3] <- mean(rajasthan_education_female_middlehigh$q20==1)
descriptives_r_f_ed_4[7,4] <- mean(rajasthan_education_female_greaterhigh$q20==1)

descriptives_r_f_ed_4[8,1] <- mean(rajasthan_education_female_illiteratenoformal$q20==2)
descriptives_r_f_ed_4[8,2] <- mean(rajasthan_education_female_primary$q20==2)
descriptives_r_f_ed_4[8,3] <- mean(rajasthan_education_female_middlehigh$q20==2)
descriptives_r_f_ed_4[8,4] <- mean(rajasthan_education_female_greaterhigh$q20==2)

descriptives_r_f_ed_4[9,1] <- mean(rajasthan_education_female_illiteratenoformal$q20==3)
descriptives_r_f_ed_4[9,2] <- mean(rajasthan_education_female_primary$q20==3)
descriptives_r_f_ed_4[9,3] <- mean(rajasthan_education_female_middlehigh$q20==3)
descriptives_r_f_ed_4[9,4] <- mean(rajasthan_education_female_greaterhigh$q20==3)

descriptives_r_f_ed_4[10,1] <- mean(rajasthan_education_female_illiteratenoformal$q20==4) + mean(rajasthan_education_female_illiteratenoformal$q20==5) + mean(rajasthan_education_female_illiteratenoformal$q20==6) + mean(rajasthan_education_female_illiteratenoformal$q20==7)
descriptives_r_f_ed_4[10,2] <- mean(rajasthan_education_female_primary$q20==4) + mean(rajasthan_education_female_primary$q20==5) + mean(rajasthan_education_female_primary$q20==6) + mean(rajasthan_education_female_primary$q20==7)
descriptives_r_f_ed_4[10,3] <- mean(rajasthan_education_female_middlehigh$q20==4) + mean(rajasthan_education_female_middlehigh$q20==5) + mean(rajasthan_education_female_middlehigh$q20==6) + mean(rajasthan_education_female_middlehigh$q20==7)
descriptives_r_f_ed_4[10,4] <- mean(rajasthan_education_female_greaterhigh$q20==4) + mean(rajasthan_education_female_greaterhigh$q20==5) + mean(rajasthan_education_female_greaterhigh$q20==6) + mean(rajasthan_education_female_greaterhigh$q20==7)

#religion
#1=hindu, 2=muslim, 3=christian, 4=sikh, 6=jain
descriptives_r_f_ed_4[11,1] <- ""
descriptives_r_f_ed_4[11,2] <- ""
descriptives_r_f_ed_4[11,3] <- ""
descriptives_r_f_ed_4[11,4] <- ""

descriptives_r_f_ed_4[12,1] <- mean(rajasthan_education_female_illiteratenoformal$Religion_Hindu==1)
descriptives_r_f_ed_4[12,2] <- mean(rajasthan_education_female_primary$Religion_Hindu==1)
descriptives_r_f_ed_4[12,3] <- mean(rajasthan_education_female_middlehigh$Religion_Hindu==1)
descriptives_r_f_ed_4[12,4] <- mean(rajasthan_education_female_greaterhigh$Religion_Hindu==1)

descriptives_r_f_ed_4[13,1] <- mean(rajasthan_education_female_illiteratenoformal$Religion_Muslim==1)
descriptives_r_f_ed_4[13,2] <- mean(rajasthan_education_female_primary$Religion_Muslim==1)
descriptives_r_f_ed_4[13,3] <- mean(rajasthan_education_female_middlehigh$Religion_Muslim==1)
descriptives_r_f_ed_4[13,4] <- mean(rajasthan_education_female_greaterhigh$Religion_Muslim==1)

#caste of head of household
#1=general, 2=obc, 3=scheduled caste, 4=scheduled tribe, 9=dk/cs
descriptives_r_f_ed_4[14,1] <- ""
descriptives_r_f_ed_4[14,2] <- ""
descriptives_r_f_ed_4[14,3] <- ""
descriptives_r_f_ed_4[14,4] <- ""

descriptives_r_f_ed_4[15,1] <- mean(rajasthan_education_female_illiteratenoformal$Caste_General==1)
descriptives_r_f_ed_4[15,2] <- mean(rajasthan_education_female_primary$Caste_General==1)
descriptives_r_f_ed_4[15,3] <- mean(rajasthan_education_female_middlehigh$Caste_General==1)
descriptives_r_f_ed_4[15,4] <- mean(rajasthan_education_female_greaterhigh$Caste_General==1)

descriptives_r_f_ed_4[16,1] <- mean(rajasthan_education_female_illiteratenoformal$Caste_OBC==1)
descriptives_r_f_ed_4[16,2] <- mean(rajasthan_education_female_primary$Caste_OBC==1)
descriptives_r_f_ed_4[16,3] <- mean(rajasthan_education_female_middlehigh$Caste_OBC==1)
descriptives_r_f_ed_4[16,4] <- mean(rajasthan_education_female_greaterhigh$Caste_OBC==1)

descriptives_r_f_ed_4[17,1] <- mean(rajasthan_education_female_illiteratenoformal$Caste_ScheduledCaste==1)
descriptives_r_f_ed_4[17,2] <- mean(rajasthan_education_female_primary$Caste_ScheduledCaste==1)
descriptives_r_f_ed_4[17,3] <- mean(rajasthan_education_female_middlehigh$Caste_ScheduledCaste==1)
descriptives_r_f_ed_4[17,4] <- mean(rajasthan_education_female_greaterhigh$Caste_ScheduledCaste==1)

descriptives_r_f_ed_4[18,1] <- mean(rajasthan_education_female_illiteratenoformal$Caste_ScheduledTribe==1)
descriptives_r_f_ed_4[18,2] <- mean(rajasthan_education_female_primary$Caste_ScheduledTribe==1)
descriptives_r_f_ed_4[18,3] <- mean(rajasthan_education_female_middlehigh$Caste_ScheduledTribe==1)
descriptives_r_f_ed_4[18,4] <- mean(rajasthan_education_female_greaterhigh$Caste_ScheduledTribe==1)

#Tabulations
#total number of adults
descriptives_r_f_ed_4[19,1] <- mean(rajasthan_education_female_illiteratenoformal$NumberAdults)
descriptives_r_f_ed_4[19,2] <- mean(rajasthan_education_female_primary$NumberAdults)
descriptives_r_f_ed_4[19,3] <- mean(rajasthan_education_female_middlehigh$NumberAdults)
descriptives_r_f_ed_4[19,4] <- mean(rajasthan_education_female_greaterhigh$NumberAdults)

#total number of children < 18
descriptives_r_f_ed_4[20,1] <- mean(rajasthan_education_female_illiteratenoformal$NumberChildrenUnder18)
descriptives_r_f_ed_4[20,2] <- mean(rajasthan_education_female_primary$NumberChildrenUnder18)
descriptives_r_f_ed_4[20,3] <- mean(rajasthan_education_female_middlehigh$NumberChildrenUnder18)
descriptives_r_f_ed_4[20,4] <- mean(rajasthan_education_female_greaterhigh$NumberChildrenUnder18)

# Monthly expenditure

descriptives_r_f_ed_4[21,1] <- median(rajasthan_education_female_illiteratenoformal$totalexpenditure, na.rm=F)
descriptives_r_f_ed_4[21,2] <- median(rajasthan_education_female_primary$totalexpenditure, na.rm=F)
descriptives_r_f_ed_4[21,3] <- median(rajasthan_education_female_middlehigh$totalexpenditure, na.rm=F)
descriptives_r_f_ed_4[21,4] <- median(rajasthan_education_female_greaterhigh$totalexpenditure, na.rm=F)

#Fuel expenditure
descriptives_r_f_ed_4[22,1] <- median(rajasthan_education_female_illiteratenoformal$q30a1_3)
descriptives_r_f_ed_4[22,2] <- median(rajasthan_education_female_primary$q30a1_3)
descriptives_r_f_ed_4[22,3] <- median(rajasthan_education_female_middlehigh$q30a1_3)
descriptives_r_f_ed_4[22,4] <- median(rajasthan_education_female_greaterhigh$q30a1_3)

descriptives_r_f_ed_4

# stargazer(descriptives_r_f_ed_4, summary=FALSE, float=FALSE, digits = 2, 
#           out = "~/Tables/supp_rajasthan_fem_ed_sumstats.tex")



# Table A7: -------------------------------------------------------------
# Summary of perceptions and indices in Kerala and Rajasthan.
# Generated by hand




# Table A8: -------------------------------------------------------------
# Summary statistics of dependent, explanatory, and control variables in Kerala households, 
# by above and below the median (logarithmized) monthly household expenditures.



k_descriptives_AMI_BMI <- data.frame(matrix(NA, 22, 2))
rownames(k_descriptives_AMI_BMI) <- c("Households (N)", "Has LPG", "Fraction Rural", "Age Respondent", "Male Chief Wage Earner", 
                                    "Relationship of Respondent to CWE:", "CWE herself", "Wife", "Daughter/DIL", "Other", 
                                    "Religion:", "Hindu", "Muslim",
                                    "Head of Household Caste:", "General", "OBC","Scheduled Caste", "Scheduled Tribe", 
                                    "Mean # Adults", "Mean # Children (<18 yrs old)",
                                    "Median Total Monthly Expenditure", "Median Monthly Fuel Expenditures")

colnames(k_descriptives_AMI_BMI) <- c("Below Median Income Households", "Above Median Income Households")

# N
k_descriptives_AMI_BMI[1,1] <- nrow(kerala_belowmedian_income)
k_descriptives_AMI_BMI[1,2] <- nrow(kerala_abovemedian_income)

# Owns LPG
k_descriptives_AMI_BMI[2,1] <- mean(kerala_belowmedian_income$Owns_LPG)
k_descriptives_AMI_BMI[2,2] <- mean(kerala_abovemedian_income$Owns_LPG)


# Rural==1, Urban==2
k_descriptives_AMI_BMI[3,1] <- mean(kerala_belowmedian_income$Rural==1)
k_descriptives_AMI_BMI[3,2] <- mean(kerala_abovemedian_income$Rural==1)

# Age of respondent (female > 18 yrs)
k_descriptives_AMI_BMI[4,1] <- mean(kerala_belowmedian_income$AgeRespondent)
k_descriptives_AMI_BMI[4,2] <- mean(kerala_abovemedian_income$AgeRespondent)

# Gender Chief Wage Earner (Male=1; Female=2)
k_descriptives_AMI_BMI[5,1] <- mean(kerala_belowmedian_income$q7==1)
k_descriptives_AMI_BMI[5,2] <- mean(kerala_abovemedian_income$q7==1)

# Relationship of respondent to CWE
# 1=CWE, 2=wife, 3=daughter/DIL, 4=granddaughter, 5=mother, 6=sister/SIL, 7=other

k_descriptives_AMI_BMI[6,1] <- ""
k_descriptives_AMI_BMI[6,2] <- ""

k_descriptives_AMI_BMI[7,1] <- mean(kerala_belowmedian_income$q20==1)
k_descriptives_AMI_BMI[7,2] <- mean(kerala_abovemedian_income$q20==1)

k_descriptives_AMI_BMI[8,1] <- mean(kerala_belowmedian_income$q20==2)
k_descriptives_AMI_BMI[8,2] <- mean(kerala_abovemedian_income$q20==2)

k_descriptives_AMI_BMI[9,1] <- mean(kerala_belowmedian_income$q20==3)
k_descriptives_AMI_BMI[9,2] <- mean(kerala_abovemedian_income$q20==3)

k_descriptives_AMI_BMI[10,1] <- mean(kerala_belowmedian_income$q20==4) + mean(kerala_belowmedian_income$q20==5) + mean(kerala_belowmedian_income$q20==6) + mean(kerala_belowmedian_income$q20==7)
k_descriptives_AMI_BMI[10,2] <- mean(kerala_abovemedian_income$q20==4) + mean(kerala_abovemedian_income$q20==5) + mean(kerala_abovemedian_income$q20==6) + mean(kerala_abovemedian_income$q20==7)

#religion
#1=hindu, 2=muslim, 3=christian, 4=sikh, 6=jain
k_descriptives_AMI_BMI[11,1] <- ""
k_descriptives_AMI_BMI[11,2] <- ""

k_descriptives_AMI_BMI[12,1] <- mean(kerala_belowmedian_income$Religion_Hindu==1)
k_descriptives_AMI_BMI[12,2] <- mean(kerala_abovemedian_income$Religion_Hindu==1)

k_descriptives_AMI_BMI[13,1] <- mean(kerala_belowmedian_income$Religion_Muslim==1)
k_descriptives_AMI_BMI[13,2] <- mean(kerala_abovemedian_income$Religion_Muslim==1)

#caste of head of household
#1=general, 2=obc, 3=scheduled caste, 4=scheduled tribe, 9=dk/cs
k_descriptives_AMI_BMI[14,1] <- ""
k_descriptives_AMI_BMI[14,2] <- ""

k_descriptives_AMI_BMI[15,1] <- mean(kerala_belowmedian_income$Caste_General==1)
k_descriptives_AMI_BMI[15,2] <- mean(kerala_abovemedian_income$Caste_General==1)

k_descriptives_AMI_BMI[16,1] <- mean(kerala_belowmedian_income$Caste_OBC==1)
k_descriptives_AMI_BMI[16,2] <- mean(kerala_abovemedian_income$Caste_OBC==1)

k_descriptives_AMI_BMI[17,1] <- mean(kerala_belowmedian_income$Caste_ScheduledCaste==1)
k_descriptives_AMI_BMI[17,2] <- mean(kerala_abovemedian_income$Caste_ScheduledCaste==1)

k_descriptives_AMI_BMI[18,1] <- mean(kerala_belowmedian_income$Caste_ScheduledTribe==1)
k_descriptives_AMI_BMI[18,2] <- mean(kerala_abovemedian_income$Caste_ScheduledTribe==1)

#Tabulations
#total number of adults
k_descriptives_AMI_BMI[19,1] <- mean(kerala_belowmedian_income$NumberAdults)
k_descriptives_AMI_BMI[19,2] <- mean(kerala_abovemedian_income$NumberAdults)

#total number of children < 18
k_descriptives_AMI_BMI[20,1] <- mean(kerala_belowmedian_income$NumberChildrenUnder18)
k_descriptives_AMI_BMI[20,2] <- mean(kerala_abovemedian_income$NumberChildrenUnder18)

# Monthly expenditure

k_descriptives_AMI_BMI[21,1] <- median(kerala_belowmedian_income$totalexpenditure, na.rm=F)
k_descriptives_AMI_BMI[21,2] <- median(kerala_abovemedian_income$totalexpenditure, na.rm=F)

#Fuel expenditure
k_descriptives_AMI_BMI[22,1] <- median(kerala_belowmedian_income$q30a1_3)
k_descriptives_AMI_BMI[22,2] <- median(kerala_abovemedian_income$q30a1_3)

k_descriptives_AMI_BMI

# stargazer(k_descriptives_AMI_BMI, summary=FALSE, float=FALSE, digits = 2, digits.extra=2,
#           out = "~/Tables/ker_ami_bmi_sumstats.tex")



# Table A9: -------------------------------------------------------------

# Summary statistics of dependent, explanatory, and control variables in Rajasthan households, 
# by above and below the median (logarithmized) monthly household expenditures.


r_descriptives_AMI_BMI <- data.frame(matrix(NA, 22, 2))
rownames(r_descriptives_AMI_BMI) <- c("Households (N)", "Has LPG", "Fraction Rural", "Age Respondent", "Male Chief Wage Earner", 
                                    "Relationship of Respondent to CWE:", "CWE herself", "Wife", "Daughter/DIL", "Other", 
                                    "Religion:", "Hindu", "Muslim",
                                    "Head of Household Caste:", "General", "OBC","Scheduled Caste", "Scheduled Tribe", 
                                    "Mean # Adults", "Mean # Children (<18 yrs old)",
                                    "Median Total Monthly Expenditure", "Median Monthly Fuel Expenditures")

colnames(r_descriptives_AMI_BMI) <- c("Below Median Income Households", "Above Median Income Households")

# N
r_descriptives_AMI_BMI[1,1] <- nrow(rajasthan_belowmedian_income)
r_descriptives_AMI_BMI[1,2] <- nrow(rajasthan_abovemedian_income)

# Owns LPG
r_descriptives_AMI_BMI[2,1] <- mean(rajasthan_belowmedian_income$Owns_LPG)
r_descriptives_AMI_BMI[2,2] <- mean(rajasthan_abovemedian_income$Owns_LPG)


# Rural==1, Urban==2
r_descriptives_AMI_BMI[3,1] <- mean(rajasthan_belowmedian_income$Rural==1)
r_descriptives_AMI_BMI[3,2] <- mean(rajasthan_abovemedian_income$Rural==1)

# Age of respondent (female > 18 yrs)
r_descriptives_AMI_BMI[4,1] <- mean(rajasthan_belowmedian_income$AgeRespondent)
r_descriptives_AMI_BMI[4,2] <- mean(rajasthan_abovemedian_income$AgeRespondent)

# Gender Chief Wage Earner (Male=1; Female=2)
r_descriptives_AMI_BMI[5,1] <- mean(rajasthan_belowmedian_income$q7==1)
r_descriptives_AMI_BMI[5,2] <- mean(rajasthan_abovemedian_income$q7==1)

# Relationship of respondent to CWE
# 1=CWE, 2=wife, 3=daughter/DIL, 4=granddaughter, 5=mother, 6=sister/SIL, 7=other

r_descriptives_AMI_BMI[6,1] <- ""
r_descriptives_AMI_BMI[6,2] <- ""

r_descriptives_AMI_BMI[7,1] <- mean(rajasthan_belowmedian_income$q20==1)
r_descriptives_AMI_BMI[7,2] <- mean(rajasthan_abovemedian_income$q20==1)

r_descriptives_AMI_BMI[8,1] <- mean(rajasthan_belowmedian_income$q20==2)
r_descriptives_AMI_BMI[8,2] <- mean(rajasthan_abovemedian_income$q20==2)

r_descriptives_AMI_BMI[9,1] <- mean(rajasthan_belowmedian_income$q20==3)
r_descriptives_AMI_BMI[9,2] <- mean(rajasthan_abovemedian_income$q20==3)

r_descriptives_AMI_BMI[10,1] <- mean(rajasthan_belowmedian_income$q20==4) + mean(rajasthan_belowmedian_income$q20==5) + mean(rajasthan_belowmedian_income$q20==6) + mean(rajasthan_belowmedian_income$q20==7)
r_descriptives_AMI_BMI[10,2] <- mean(rajasthan_abovemedian_income$q20==4) + mean(rajasthan_abovemedian_income$q20==5) + mean(rajasthan_abovemedian_income$q20==6) + mean(rajasthan_abovemedian_income$q20==7)

#religion
#1=hindu, 2=muslim, 3=christian, 4=sikh, 6=jain
r_descriptives_AMI_BMI[11,1] <- ""
r_descriptives_AMI_BMI[11,2] <- ""

r_descriptives_AMI_BMI[12,1] <- mean(rajasthan_belowmedian_income$Religion_Hindu==1)
r_descriptives_AMI_BMI[12,2] <- mean(rajasthan_abovemedian_income$Religion_Hindu==1)

r_descriptives_AMI_BMI[13,1] <- mean(rajasthan_belowmedian_income$Religion_Muslim==1)
r_descriptives_AMI_BMI[13,2] <- mean(rajasthan_abovemedian_income$Religion_Muslim==1)

#caste of head of household
#1=general, 2=obc, 3=scheduled caste, 4=scheduled tribe, 9=dk/cs
r_descriptives_AMI_BMI[14,1] <- ""
r_descriptives_AMI_BMI[14,2] <- ""

r_descriptives_AMI_BMI[15,1] <- mean(rajasthan_belowmedian_income$Caste_General==1)
r_descriptives_AMI_BMI[15,2] <- mean(rajasthan_abovemedian_income$Caste_General==1)

r_descriptives_AMI_BMI[16,1] <- mean(rajasthan_belowmedian_income$Caste_OBC==1)
r_descriptives_AMI_BMI[16,2] <- mean(rajasthan_abovemedian_income$Caste_OBC==1)

r_descriptives_AMI_BMI[17,1] <- mean(rajasthan_belowmedian_income$Caste_ScheduledCaste==1)
r_descriptives_AMI_BMI[17,2] <- mean(rajasthan_abovemedian_income$Caste_ScheduledCaste==1)

r_descriptives_AMI_BMI[18,1] <- mean(rajasthan_belowmedian_income$Caste_ScheduledTribe==1)
r_descriptives_AMI_BMI[18,2] <- mean(rajasthan_abovemedian_income$Caste_ScheduledTribe==1)

#Tabulations
#total number of adults
r_descriptives_AMI_BMI[19,1] <- mean(rajasthan_belowmedian_income$NumberAdults)
r_descriptives_AMI_BMI[19,2] <- mean(rajasthan_abovemedian_income$NumberAdults)

#total number of children < 18
r_descriptives_AMI_BMI[20,1] <- mean(rajasthan_belowmedian_income$NumberChildrenUnder18)
r_descriptives_AMI_BMI[20,2] <- mean(rajasthan_abovemedian_income$NumberChildrenUnder18)

# Monthly expenditure

r_descriptives_AMI_BMI[21,1] <- median(rajasthan_belowmedian_income$totalexpenditure, na.rm=F)
r_descriptives_AMI_BMI[21,2] <- median(rajasthan_abovemedian_income$totalexpenditure, na.rm=F)

#Fuel expenditure
r_descriptives_AMI_BMI[22,1] <- median(rajasthan_belowmedian_income$q30a1_3)
r_descriptives_AMI_BMI[22,2] <- median(rajasthan_abovemedian_income$q30a1_3)


r_descriptives_AMI_BMI

# stargazer(r_descriptives_AMI_BMI, summary=FALSE, float=FALSE, digits = 2, digits.extra=2,
#           out = "~/Tables/raj_ami_bmi_sumstats.tex")





